/**
 * @从一个字符串中裁减一个字符串
 * @看一下substring函数里面的错误
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>

void substring(const char source[], int start, int count);

int main(int argc, char *argv[]) {
	const char s[] = {"abcdefghijklmnopqrstuvwxyz"};
	int i, n;

	printf("%s\n", s);

	printf("请输入一个下标：");
	scanf("%d", &i);
	printf("请输入要裁减个数：");
	scanf("%d", &n);

	printf("%c\n", substring(s, i, n));

	return 0;
}

void substring(const char source[], int start, int count) {
	int i = 0;
	char c[20];

	for (int j=source[start]; j<source[start + count]; j++) {
		c[i] = j;
		i++;
	}

	c[i] = '\0'; 
}
